﻿@model NFine.Domain._03_Entity.Weixin.CompanyEntity
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>申请加入</title>
    <link rel="stylesheet" href="//cdn.bootcss.com/jquery-weui/1.0.1/css/jquery-weui.min.css">
    <link rel="stylesheet" href="//cdn.bootcss.com/weui/1.1.1/style/weui.min.css">
    <script src="//cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
    <script src="//cdn.bootcss.com/jquery-weui/1.0.1/js/jquery-weui.min.js"></script>
    <script src="~/Content/js/ajaxfileupload.js" type="text/javascript"></script>
    <!-- 字体图标 -->
    <link rel="stylesheet" href="~/Content/M/css/iconfonts.css" />
    <!-- 图片截取 -->
    @*<link rel="stylesheet" href="~/Content/M/css/photoclip.css" />*@
    <style>
       .title {
    /*margin-top: 0.3rem;
    padding-left: 15px;
    font-size: 18px;*/
    margin-left:5rem;
}
       .wait:before{
           width:0px;
       }
        .wait:after{
           width:0px;
       }
        /*头部*/
        header {
            position: absolute;
            top: 0;
            z-index: 10;
            width: 100%;
            max-width: 640px;
            color: #555;
            box-shadow: 1px 1px 10px rgba(0,0,0,.1);
            /*-webkit-justify-content: space-between;
            -webkit-align-items: center;*/
            /*-webkit-transition: .3s ease all;*/
        }
        .header {
            background-color: #fff;
            height: 45px;
            line-height: 45px;
            font-size: 1rem;
        }
        .icon{
            font-family:'icomoon' !important;
        }
            .icon:before {
                content: "\e90e";
            }
            a{
            color: #555;
            }
    </style>

</head>
<body>
    <header class="header">
        <span style="margin-left:0.5rem;">
            <a  href="javascript:location.replace('Index')">
                <span  class="icon"></span>
            </a>
        </span>
        <span class="title"><strong>公司信息 </strong></span>
    </header>
    
    @*<div class="title"><strong>公司信息 </strong></div>*@ 
    <form id="form1">
        <input type="hidden" id="Logo" name="Logo">
        <div class="weui-cells " style="margin-top:45px">
            <div class="weui-cell">
                <div class="weui-cell__hd" style="margin-bottom:2.5rem"><label class="weui-label">公司Logo</label></div>
                <div class="weui-cell__bd">
                    <div class="weui-uploader__input-box" >
                        <input id="uploaderInput" name="uploaderInput" class="weui-uploader__input" type="file" accept="image/*" onchange="uploadFile()">
                        <img id="fileImg" class="weui-uploader__input" src="~/Content/M/img/refresh.gif" style="opacity:inherit" hidden />
                        <img id="RefreshImg"  src="~/Content/M/img/refresh1.gif" style="opacity:inherit;margin:30%"  hidden/>
                        @*<ul style="list-style:none" id="ulRefresh">
                            <li class="weui-uploader__file weui-uploader__file_status" >
                                <div class="weui-uploader__file-content">50%</div>
                            </li>
                        </ul>*@

                        <div id="view"></div>
                    </div>
                   
                </div>

            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">公司名称</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" placeholder="请输入公司名称" required id="Name" name="Name" value="@Model.Name">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">经营项目</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" placeholder="请输入经营项目" id="BusinessProject" name="BusinessProject" value="@Model.BusinessProject">
                </div>
            </div>
            @*<div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label">公司电话</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="tel" placeholder="请输入公司电话" required id="Telephone" name="Telephone" >
                </div>
            </div>*@
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="" class="weui-label">联系人</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" placeholder="请输入联系人" required id="Contact" name="Contact" value="@Model.Contact">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label for="" class="weui-label">联系电话</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="tel" placeholder="请输入联系电话" required id="ContactPhone" name="ContactPhone" value="@Model.ContactPhone">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">公司地址</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" type="text" placeholder="请输入公司地址" required id="Address" name="Address" value="@Model.Address">
                </div>
            </div>
        </div>
        <div style="margin-top:10px">
            <a id="btnSubmit" href="javascript:submit();" class="weui-btn weui-btn_primary">提交<i class="weui-loading" style="display:none;"></i></a>
        </div>
    </form>

    @*<div class="photo-box">
        <div id="clipArea"></div>
        <button id="clipBtn">截取</button>
    </div>*@
    <!-- 图片截取 -->
    @*<script type="text/javascript" src="~/Content/M/js/iscroll-zoom.js"></script>
    <script type="text/javascript" src="~/Content/M/js/hammer.js"></script>
    <script type="text/javascript" src="~/Content/M/js/lrz.all.bundle.js"></script>
    <script type="text/javascript" src="~/Content/M/js/jquery.photoClip.js"></script>*@
        <script type="text/javascript">
           //图片截取 
          /*  var cir_thumb;
            var clipArea = new bjj.PhotoClip("#clipArea", {
                size: [260, 260],//剪裁完成的图片height，width
                outputSize: [640, 640],//剪裁框的height，width
                file: "#uploaderInput",//文件上传框ID
                view: "#view", //预览div的ID
                ok: "#clipBtn",//剪裁开始按钮ID
                loadStart: function() {
                    // console.log("照片读取中");
                    $('.photo-box').fadeIn();
                },
                loadComplete: function() {
                    // console.log("照片读取完成");
                },
                clipFinish: function(dataURL) {alert(1);
                    $.ajax({
                        url: "/Companys/upload_cut",
                        dataType: 'json',
                        data:"base64Img="+dataURL,
                        type: 'post',
                        success: function (_data) {
                            alert(_data);
                        }
                    });
                    $('.photo-box, .pafull-box').fadeOut();

                }
            });*/



              @*if ( @ViewData["state"] >-1)//已申请 
              {
                  $("input").attr("readonly","readonly");
                  $("#uploaderInput").hide();
                  $("#fileImg").show();
                  $("#fileImg").attr("src", "@Model.Logo");
                  if ( @ViewData["state"] ==0)// 未审核
                  {
                      $("#btnSubmit").text("请等待审核……").removeAttr("href");
                  }else{
                      $("#btnSubmit").hide();
                  }
              }*@

            function uploadFile() {
               // $("#uploaderInput").hide();
                $("#RefreshImg").show();
                $(".weui-uploader__input-box").addClass("wait");
                $.ajaxFileUpload({
                    url: "/Companys/uploadLogo",
                    type: 'post',
                    dataType: 'json',
                    timeout: 10000,
                    fileElementId: "uploaderInput",
                    success: function (data) {
                        $("#RefreshImg").hide();
                        $(".weui-uploader__input-box").removeClass("wait");
                        if (data.msg == 0) {
                            $.toptip('上传图片出错', 'error');
                            $("#uploaderInput").show();
                            $("#fileImg").hide();
                        } else {
                            $("#fileImg").show();
                            var path = "/UploadFiles/temp/" + data.msg;
                            $("#Logo").val(data.msg);
                            $("#fileImg").attr("src", path);
                        }
                    }
                });
            }
            $("#fileImg").click(function () {
                $("#uploaderInput").click();
            });
            function submit() {
                if (yan() != false) {
                    $(".weui-loading").show();
                    $.ajax({
                        url: "/Companys/submit",
                        data: $("#form1").serialize(),
                        dataType: 'json',
                        type: 'post',
                        success: function (_data) {
                            if (_data > 0) {
                                location.replace("WaitAudit");
                              //  $.toptip('申请成功，请等待审核……');
                              //  $(".weui-loading").hide();
                              //  //$("input").val("");
                              // // $("#fileImg").hide();
                              ////  $("#uploaderInput").show();
                              ////  $(".weui-uploader__input-box").removeClass("wait");

                              //  $("input").attr("readonly","readonly");
                              //  $("#btnSubmit").text("请等待审核……").removeAttr("href");
                            } else {
                                $.alert("申请失败！");
                            }
                        }
                    });
                }
            }
            function yan() {
                if ($("#Logo").val() == '') {
                    $.alert("请上传公司Logo!");
                    return false;
                }
                if ($("#Name").val() == '') {
                    $.alert("请输入公司名称!");
                    return false;
                }
                //var tele = $('#Telephone').val();
                //if (tele == '') {
                //    $.alert("请输入公司电话!");
                //    return false;
                //}
                //if (!(/^\d{3,4}-\d{7,8}$/).test(tele)) {
                //    $.alert("公司电话有误，请重填!");
                //    return false;
                //}
                if ($("#Contact").val() == '') {
                    $.alert("请输入联系人!");
                    return false;
                }
                var haoma = $('#ContactPhone').val();
                if (haoma == '') {
                    $.alert("请输入联系电话!");
                    return false;
                }
                if (!(/^1[34578]\d{9}$/.test(haoma))) {
                    $.alert("联系电话有误，请重填!");
                    return false;
                }
                if ($('#Address').val() == '') {
                    $.alert("请输入公司地址!");
                    return false;
                }
                return true;
            }
        </script>
</body>
</html>
